package connectionpool.testapp;

import connectionpool.ConnectionPool;
import connectionpool.internal.ConnectionPoolFactory;
import connectionpool.internal.DbProperties;

/**
 * @author amahmood
 * Test class. It is duplicate from integration test package. 
 * Will be removed after demo;
 */
public class TestApp
{

    /**
     * @param args
     */
    public static void main(String[] args)
    {

        runTest();
    }

    /**
     * 
     */
    public  static void runTest()
    {
        System.out.println("------ Start testConcurrency-----");
        ConnectionPool connectionPool =  ConnectionPoolFactory.getConnectionPool(5, DbProperties.getDefaultProperties());
        
        for (int i = 0; i < 10; i++)
        {
            WorkerThread appThread = new WorkerThread(connectionPool);
            Thread t1 = new Thread(appThread);
            t1.setName("testthread" + i);
            t1.start();

            try
            {
                Thread.sleep(RandomNumberUtil.nextInt(1000));
            }
            catch (InterruptedException e)
            {
                System.err.println("Some thing to worry about. " + e.getMessage() + " " + e);
            }
        }
        System.out.println("------ End testConcurrency-----");
    }

}
